class A:
    __flag = False
    def __new__(cls):
        if not hasattr(cls,'xihuo'):
            cls.xihuo=super().__new__(cls)
        return cls.xihuo
    def __init__(self):
        if not self.__flag:
            print('实例化')
            self.__flag=True
xihuo1=A()
xihuo2=A()
print(id(xihuo1),id(xihuo2))


# class A:
#     __flag = False
#     __instance = None
#     def __new__(cls,*args,**kwargs):
#
#         if cls.__instance is None:
#             cls.__instance=super().__new__(cls)
#         return cls.__instance
#     def __init__(self):
#         if not self.__flag:
#             print('实例化')
#             self.__flag=True
# xihuo1=A()
# xihuo2=A()
# print(id(xihuo1),id(xihuo2))